#ifndef INVOICEITEMMODEL_H
#define INVOICEITEMMODEL_H

#include "InvoiceItem.h"

#include <QStandardItemModel>

class InvoiceItemsModel : public QStandardItemModel
 {
     Q_OBJECT

 public:

    static const int s_columns;

    enum COLUMN
    {
        ITEM_QUANTITY                           = 0,
        ITEM_WEIGHT                             = 1,
        ITEM_PRODUCT_NAME                       = 2,
        ITEM_UNTAXED_PRICE_UNIT_OR_KILO         = 3,
        ITEM_UNTAXED_PRICE_WITHOUT_DISCOUNT     = 4,
        ITEM_DISCOUNT_RATE                      = 5,
        ITEM_DISCOUNT_EUR                       = 6,
        ITEM_TOTAL_UNTAXED_PRICE                = 7,
        ITEM_TAX_RATE                           = 8,
        ITEM_TAXES                              = 9,
        ITEM_TOTAL_PRICE                        = 10,
        ITEM_PRICE_TYPE                         = 11,
        ITEM_UNIQUE_ID                          = 12
    };

    InvoiceItemsModel( const std::vector< ecocity::InvoiceItem >& invoice_items,
                       QObject *parent = 0 );

    void reset( const std::vector< ecocity::InvoiceItem >& invoice_items );

    QVariant headerData( int section, Qt::Orientation orientation, int role ) const;

    Qt::ItemFlags flags( const QModelIndex & index ) const;

    bool add_new_invoice_item( const ecocity::InvoiceItem& invoice_item );

    const ecocity::InvoiceItem* invoice_item( const QModelIndex& index ) const;

    void save( const QString& file_name ) const;
    //bool load( const QString& file_name );

signals:

    void model_changed( );

private:

    std::vector< ecocity::InvoiceItem > m_items;
 };


#endif // INVOICEITEMMODEL_H
